package com.entmanage.base.collegeco.controller;


import com.entmanage.base.collegeco.domain.CollegecoEvalTemplateItem;
import com.entmanage.base.collegeco.service.ICollegecoEvalTemplateService;
import io.swagger.annotations.Api;

import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import javax.xml.transform.Result;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.entmanage.common.annotation.Log;
import com.entmanage.common.core.controller.BaseController;
import com.entmanage.common.core.domain.AjaxResult;
import com.entmanage.common.enums.BusinessType;
import com.entmanage.base.collegeco.domain.CollegecoEvalTemplate;
import com.entmanage.common.utils.poi.ExcelUtil;
import com.entmanage.common.core.page.TableDataInfo;

/**
 * 实习评分标准模板库（主）Controller
 *
 * @author lsq
 * @date 2025-08-01
 */
@Api(tags = {"collegeco-HrmEvalTemplate模块"}, description = "实习评分标准模板库（主）")
@RestController
@RequestMapping("/collegeco/internTemplate")
public class CollegecoEvalTemplateController extends BaseController
{
    @Autowired
    private ICollegecoEvalTemplateService hrmEvalTemplateService;

    /**
     * 查询实习评分标准模板库（主）列表
     */
    @PreAuthorize("@ss.hasPermi('collegeco:internTemplate:list')")
    @GetMapping("/list")
    public TableDataInfo list(CollegecoEvalTemplate hrmEvalTemplate)
    {
        startPage();
        List<CollegecoEvalTemplate> list = hrmEvalTemplateService.selectHrmEvalTemplateList(hrmEvalTemplate);
        return getDataTable(list);
    }

    /**
     * 导出实习评分标准模板库（主）列表
     */
    @PreAuthorize("@ss.hasPermi('collegeco:internTemplate:export')")
    @Log(title = "实习评分标准模板库（主）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CollegecoEvalTemplate hrmEvalTemplate)
    {
        List<CollegecoEvalTemplate> list = hrmEvalTemplateService.selectHrmEvalTemplateList(hrmEvalTemplate);
        ExcelUtil<CollegecoEvalTemplate> util = new ExcelUtil<CollegecoEvalTemplate>(CollegecoEvalTemplate.class);
        util.exportExcel(response, list, "实习评分标准模板库（主）数据");
    }

    /**
     * 获取实习评分标准模板库（主）详细信息
     */
    @PreAuthorize("@ss.hasPermi('collegeco:internTemplate:query')")
    @GetMapping(value = "/{templateId}")
    public AjaxResult getInfo(@PathVariable("templateId") Long templateId)
    {
        return success(hrmEvalTemplateService.selectHrmEvalTemplateByTemplateId(templateId));
    }

    /**
     * 新增实习评分标准模板库（主）
     */
    @PreAuthorize("@ss.hasPermi('collegeco:internTemplate:add')")
    @Log(title = "实习评分标准模板库（主）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CollegecoEvalTemplate hrmEvalTemplate)
    {
        return toAjax(hrmEvalTemplateService.insertHrmEvalTemplate(hrmEvalTemplate));
    }

    /**
     * 修改实习评分标准模板库（主）
     */
    @PreAuthorize("@ss.hasPermi('collegeco:internTemplate:edit')")
    @Log(title = "实习评分标准模板库（主）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CollegecoEvalTemplate hrmEvalTemplate)
    {
        return toAjax(hrmEvalTemplateService.updateHrmEvalTemplate(hrmEvalTemplate));
    }

    /**
     * 删除实习评分标准模板库（主）
     */
    @PreAuthorize("@ss.hasPermi('collegeco:internTemplate:remove')")
    @Log(title = "实习评分标准模板库（主）", businessType = BusinessType.DELETE)
    @DeleteMapping("/{templateIds}")
    public AjaxResult remove(@PathVariable Long[] templateIds)
    {
        return toAjax(hrmEvalTemplateService.deleteHrmEvalTemplateByTemplateIds(templateIds));
    }

    @GetMapping("/getTemplateItems/{templateId}")
    public AjaxResult getTemplateItems(@PathVariable Long templateId) {
        List<CollegecoEvalTemplateItem> items = hrmEvalTemplateService.getTemplateItems(templateId);
        return AjaxResult.success(items);
    }

}

